﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace m3u
{
    internal class CReader:IReader
    {
        #region IReader Members

        public List<string> Load(string filename)
        {
            //byte[] utf8String = Encoding.UTF8.GetBytes(filename);
            List<string> FilenameArray = new List<string>();
            string line;

            StreamReader reader = new StreamReader(filename,Encoding.Default);

            while ((line = reader.ReadLine()) != null)
            {
                if (!line.StartsWith("#"))
                {
                    FilenameArray.Add(line);
                }
            }

            reader.Close();
            return FilenameArray;
        }

        #endregion

        private string Convert(string file)
        {
            Byte[] b;
            Byte[] nb;
            string encodedfile;
            char[] c;

            b = Encoding.Default.GetBytes(file);
            nb = Encoding.Convert(Encoding.Default, Encoding.UTF8, b);
            c = new char[Encoding.Default.GetCharCount(nb, 0, nb.Length)];
            Encoding.UTF8.GetChars(nb, 0, nb.Length, c, 0);
            encodedfile = new string(c);

            return encodedfile;

        }
    }
}
